
#ifndef ROPUFU_STATISTIC_CUSUM_HPP_INCLUDED
#define ROPUFU_STATISTIC_CUSUM_HPP_INCLUDED

#include "../more_math.hpp"

#include <array>
#include <cmath>
#include <cstdint>
#include <ostream>
#include <string>
#include <vector>

namespace ropufu
{
    namespace statistic
    {
        struct cusum
        {
            static const std::size_t count_streams = 1UL;
            typedef cusum type;

            private:
                //// Running minimum of the (log-likelihood) observations.
                //double m_running_minimum = 0.0;

                // Current value of the statistic.
                double m_current = 0.0;

        public:
            cusum()
            {
            }

            void reset()
            {
                this->m_current = 0.0;
            }

            double observe(double loglikelihood)
            {
                this->m_current = (this->m_current < 0.0 ? 0.0 : this->m_current) + loglikelihood;
                return this->m_current;
            }

            friend std::ostream& operator <<(std::ostream& os, const type&)
            {
                return os << "cusum";
            }
        };
    }
}

#endif // ROPUFU_STATISTIC_CUSUM_HPP_INCLUDED
